package singleton;

/**
 * 饿汉式单例模式
 */
class hungrySingleton {
    private static final hungrySingleton instance = new hungrySingleton();

    private hungrySingleton() {}

    public static hungrySingleton getInstance() {
        return instance;
    }
}

public class demo1 {
    public static void main(String[] args) {
        hungrySingleton s1 = hungrySingleton.getInstance();
        hungrySingleton s2 = hungrySingleton.getInstance();
        System.out.println(s1 == s2);
    }
}
